local oo = require("SharedLibs.BaseLib")
Require = oo.Require
local co = require("SharedLibs.CoroLib")
Debugger = require("SharedLibs.Debugger")

ICondition = require("SharedLibs.Signal.ICondition")
Property = require("SharedLibs.Signal.Property")

--[[
	Condition 是一种特殊的Property. 
	Condition的值只允许布尔型, 这使得Condition可以做布尔运算. 例如
		a = b:Or(c);  --- a, b, c, d 均为Condition对象
		a = ( b:And(c) ):Or( d )
]]
local Conditioin = oo.inherit(Property);
Conditioin:implements(ICondition)

--- 详见ICondition的定义
function Conditioin:Trigger()
	if self:GetValue() then
		self:SetValue(false);
		return false;
	else
		self:SetValue(true);
		self:SetValue(false);
		return true;
	end
end

--- 详见ICondition的定义
function Conditioin:Open()
	self:SetValue(true);
end

--- 详见ICondition的定义
function Conditioin:Close()
	self:SetValue(false);
end

return Conditioin;